<!--
  Copyright 2013-2019 the original author or authors.

  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

  http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
-->
<div class="card">
  <div class="card-header">
    <h2>Transactions</h2>
  </div>
  <div class="card-body">
    <div ng-hide="hideMainContent()">
      <div ng-include src="'template/gt-loading-overlay.html'"></div>
      <div ng-include src="'template/gt-http-error-overlay.html'"></div>
      <form gt-form-autofocus-on-first-input
            name="formCtrl"
            style="padding-top: 15px;"
            novalidate>
        <div gt-form-group
             gt-label="Slow threshold"
             gt-model="config.slowThresholdMillis"
             gt-number="true"
             gt-pattern="pattern.integer"
             gt-required="loaded"
             gt-disabled="!agentRollup.permissions.config.edit.transaction"
             gt-width="7em"
             gt-addon="milliseconds">
          <div class="help-block">
            Any transaction that exceeds this amount of time will be viewable immediately as an active trace and the
            trace will be stored to disk at its completion.
          </div>
        </div>
        <div gt-form-group
             gt-label="Profiling interval"
             gt-model="config.profilingIntervalMillis"
             gt-number="true"
             gt-pattern="pattern.integer"
             gt-required="loaded"
             gt-disabled="!agentRollup.permissions.config.edit.transaction"
             gt-width="7em"
             gt-addon="milliseconds">
          <div class="help-block">
            The interval at which the profiler samples stack traces. Each sampling time is randomized within its given
            interval in order to avoid periodicity bias.
          </div>
        </div>
        <div gt-form-group
             gt-type="checkbox"
             gt-label="Thread stats"
             gt-checkbox-label="Capture JVM thread stats"
             gt-model="config.captureThreadStats"
             gt-disabled="!agentRollup.permissions.config.edit.transaction">
          <div class="help-block">
            Capture CPU time, blocked time, waited time and allocated memory if available.
            <span ng-if="agentRollup.permissions.jvm.capabilities">
              See <a href="jvm/capabilities">JVM Capabilities</a>.
            </span>
            Capturing this data has some overhead (around 5 microseconds per transaction).
          </div>
        </div>
        <div ng-if="supportsSlowThresholdOverrides()">
          <fieldset class="gt-fieldset"
                    ng-repeat="slowThresholdOverride in config.slowThresholdOverrides">
            <legend class="gt-legend">Slow threshold override</legend>
            <div class="gt-fieldset-under-normal-form">
              <div class="form-group row">
                <label class="col-xl-3 gt-form-label-xl"
                       for="transactionType{{$index}}">
                  Transaction type
                </label>
                <div class="col-xl-9">
                  <select ng-model="slowThresholdOverride.transactionType"
                          ng-disabled="!agentRollup.permissions.config.edit.transaction"
                          id="transactionType{{$index}}"
                          class="custom-select"
                          style="width: auto;"
                          required>
                    <option ng-repeat="transactionType in allTransactionTypes"
                            ng-value="transactionType.name"
                            ng-disabled="transactionType.disabled">
                      {{transactionType.name}}
                    </option>
                  </select>
                  <div class="help-block">
                    The transaction type this override applies to.
                  </div>
                </div>
              </div>
              <div gt-form-group
                   gt-label="Transaction name"
                   gt-model="slowThresholdOverride.transactionName"
                   gt-disabled="!agentRollup.permissions.config.edit.transaction"
                   gt-width="40em">
                <div class="help-block">
                  The transaction name this override applies to. If empty, this override will apply to all transaction
                  names.
                </div>
              </div>
              <div gt-form-group
                   gt-label="User"
                   gt-model="slowThresholdOverride.user"
                   gt-disabled="!agentRollup.permissions.config.edit.transaction"
                   gt-width="40em"
                   ng-if="supportsSlowThreholdUserOverrides()">
                <div class="help-block">
                  The user this override applies to. If empty, this override will apply to all users. Case insensitive
                  comparison is performed.
                </div>
              </div>
              <div gt-form-group
                   gt-label="Slow threshold"
                   gt-model="slowThresholdOverride.thresholdMillis"
                   gt-number="true"
                   gt-pattern="pattern.integer"
                   gt-required="loaded"
                   gt-disabled="!agentRollup.permissions.config.edit.transaction"
                   gt-width="7em"
                   gt-addon="milliseconds">
              </div>
              <div class="float-right pr-xl-4 pb-2"
                   ng-if="agentRollup.permissions.config.edit.transaction">
                <button class="btn btn-secondary"
                        ng-click="removeSlowThresholdOverride(slowThresholdOverride)">
                  Remove this slow threshold override
                </button>
              </div>
            </div>
          </fieldset>
          <fieldset class="gt-fieldset"
                    ng-if="agentRollup.permissions.config.edit.transaction">
            <legend class="gt-legend">
              Add {{config.slowThresholdOverrides.length ? 'another' : 'a'}} slow threshold override
            </legend>
            <button class="btn btn-secondary"
                    ng-click="addSlowThresholdOverride()"
                    style="margin-bottom: 23px; margin-left: 14px;">
              Add
            </button>
          </fieldset>
        </div>
        <div class="form-group row"
             ng-if="agentRollup.permissions.config.edit.transaction">
          <div class="offset-xl-3 col-xl-9">
            <div gt-button
                 gt-label="Save changes"
                 gt-click="save(deferred)"
                 gt-validate-form="formCtrl">
            </div>
          </div>
        </div>
      </form>
    </div>
  </div>
</div>
<!-- each page with confirmation dialog needs its own confirmation dom so that it is deleted on $destroy -->
<div ng-include="'template/gt-confirmation.html'"></div>
